<template>
  <el-drawer v-model="table" title="编辑生成代码类型" direction="rtl" size="50%" v-on:close="Load()">
    <el-form :model="form" label-width="120px">
      <el-col :span="12">
<el-form-item label="生成代码类型名字">
<el-input v-model="table.data.makecodetype_name" placeholder="请输入生成代码类型名字" />
</el-form-item>
</el-col><el-col :span="12">
<el-form-item label="生成代码类型后缀">
<el-input v-model="table.data.makecodetype_suffix" placeholder="请输入生成代码类型后缀" />
</el-form-item>
</el-col>
    </el-form>
    <el-button type="success" v-on:click="Edit()">编辑</el-button>
  </el-drawer>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { Load, Upload, getBase64, CloseUpload } from '/src/style.js'
import { Plus } from '@element-plus/icons-vue'
import type { UploadProps, UploadUserFile } from 'element-plus'
import { EditMakecodetype } from '../../../../service/Makecodetype.js'
import { ReadImageSrc } from '/src/config.js'



const props = defineProps({
  data: Object,
})



const table = ref(props)


const form = ref()
//*上传文件
const dialogVisible = ref(false)
const UploadFile = ref()
const UploadName = ref()
const CloseUploadName = ref()
const UploadSrc = ref()


//*文件上传成功
const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile, fileList) => {
  getBase64(uploadFile.raw).then(res => {
    const params = res.split(',') //*分割类型和base64内容
    UploadFile.value = params[1]
    console.log(uploadFile)
    UploadName.value = uploadFile.name
    const data = { name: uploadFile.name, size: uploadFile.size, file: params[1], type: uploadFile.raw.type }
    Upload(data).then((res) => {
      UploadSrc.value = ReadImageSrc + UploadName.value
    })
  })
}
//*文件移除时
const handleRemove = (uploadFile) => {
  CloseUploadName.value = uploadFile.name
  const data = { name: CloseUploadName.value, type: uploadFile.raw.type }
  CloseUpload(data)
}

//*预览图片
const handlePreview = () => {
  dialogVisible.value = true
}


const Edit = (index) => {
  const data = { makecodetype_guid: props.data.makecodetype_guid, makecodetype_name:props.data.makecodetype_name,makecodetype_suffix:props.data.makecodetype_suffix, }
  EditMakecodetype(data).then((res) => {
    console.log(res)
  })
}


</script>
     
     
<style></style>